package com.skt.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.skt.common.annotation.Log;
import com.skt.common.core.controller.BaseController;
import com.skt.common.core.domain.AjaxResult;
import com.skt.common.enums.BusinessType;
import com.skt.manage.domain.Doctordepartments;
import com.skt.manage.service.IDoctordepartmentsService;
import com.skt.common.utils.poi.ExcelUtil;
import com.skt.common.core.page.TableDataInfo;

/**
 * 医生科室管理Controller
 * 
 * @author ffbaby
 * @date 2025-02-21
 */
@RestController
@RequestMapping("/manage/doctordepartments")
public class DoctordepartmentsController extends BaseController
{
    @Autowired
    private IDoctordepartmentsService doctordepartmentsService;

    /**
     * 查询医生科室管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:doctordepartments:list')")
    @GetMapping("/list")
    public TableDataInfo list(Doctordepartments doctordepartments)
    {
        startPage();
        List<Doctordepartments> list = doctordepartmentsService.selectDoctordepartmentsList(doctordepartments);
        return getDataTable(list);
    }

    /**
     * 导出医生科室管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:doctordepartments:export')")
    @Log(title = "医生科室管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Doctordepartments doctordepartments)
    {
        List<Doctordepartments> list = doctordepartmentsService.selectDoctordepartmentsList(doctordepartments);
        ExcelUtil<Doctordepartments> util = new ExcelUtil<Doctordepartments>(Doctordepartments.class);
        util.exportExcel(response, list, "医生科室管理数据");
    }

    /**
     * 获取医生科室管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:doctordepartments:query')")
    @GetMapping(value = "/{assignmentId}")
    public AjaxResult getInfo(@PathVariable("assignmentId") Long assignmentId)
    {
        return success(doctordepartmentsService.selectDoctordepartmentsByAssignmentId(assignmentId));
    }

    /**
     * 新增医生科室管理
     */
    @PreAuthorize("@ss.hasPermi('manage:doctordepartments:add')")
    @Log(title = "医生科室管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Doctordepartments doctordepartments)
    {
        return toAjax(doctordepartmentsService.insertDoctordepartments(doctordepartments));
    }

    /**
     * 修改医生科室管理
     */
    @PreAuthorize("@ss.hasPermi('manage:doctordepartments:edit')")
    @Log(title = "医生科室管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Doctordepartments doctordepartments)
    {
        return toAjax(doctordepartmentsService.updateDoctordepartments(doctordepartments));
    }

    /**
     * 删除医生科室管理
     */
    @PreAuthorize("@ss.hasPermi('manage:doctordepartments:remove')")
    @Log(title = "医生科室管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assignmentIds}")
    public AjaxResult remove(@PathVariable Long[] assignmentIds)
    {
        return toAjax(doctordepartmentsService.deleteDoctordepartmentsByAssignmentIds(assignmentIds));
    }
}
